import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children: [{
      path: '/children',
      component: () => import('../components/chilren.vue')
    }],
    // props: true
    // props: { text: "李峰" }
    // props: (route) => ({ aaa: route.params.test })
    meta: { aaa: 'wwww' },
    beforeEnter: (to, from, next) => {
      // console.log(to)
      // console.log(from)
      next()
    }
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => {
  // console.log(to)
  // console.log(from)
  next()
})

router.afterEach((to, from) => {
  // console.log(to)
  // console.log(from)
})

export default router
